import { defineConfig } from 'vite'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { viteCommonjs } from '@originjs/vite-plugin-commonjs'
import { resolve } from 'path'
const pathResolve = (pathStr: string) => {
  return resolve(__dirname + '/../', pathStr)
}
export default defineConfig({
  plugins: [
    // 添加JSX插件
    vueJsx(),
    viteCommonjs({
      include: ['node_modules/json-editor-vue3', 'node_modules/jsoneditor', 'node_modules/dayjs']
    })
  ],
  // 这里变更一下端口
  server: {
    port: 3000
  },
  resolve: {
    alias: [
      {
        find: 'vue-i18n',
        replacement: 'vue-i18n/dist/vue-i18n.cjs.js'
      },
      {
        find: '@',
        replacement: pathResolve('src') + '/'
      }
    ]
  },
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true
      }
    }
  }
})
